import unittest
from datetime import datetime
import time
from XTestRunner import HTMLTestRunner
test_root = "./testcase_demo"
suits = unittest.defaultTestLoader.discover(test_root, pattern="test_*.py")

if __name__ == '__main__':
    filename = datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d %H-%M-%S-%f")
    # time.strftime("%Y-%m-%d %H-%M-%S-%f")
    report_path = "./test_report/{0}.html".format(filename)
    with open(report_path, "wb") as fp:
        runner = HTMLTestRunner(
            stream=fp,
            tester="litan",
            title='Unittest Demo自动化测试报告',
            description=['类型：Unittest Demo', '操作系统：Windows', '浏览器：Chrome'],
            language="en"
        )

        runner.run(
            testlist=suits,
            rerun=0,
            save_last_run=False
        )